#define _CRT_SECURE_NO_WARNINGS 1

class Solution
{
public:
    string firstPalindrome(vector<string>& words)
    {
        for (auto w : words)
        {
            int i = 0, j = w.size() - 1;
            while (i < j)
            {
                if (w[i] == w[j]) {
                    i++;
                    j--;
                }
                else {
                    break;
                }
            }
            if (i == j || i == j + 1)
                return w;
        }

        return "";
    }
};